from typing import List
# 先转置，再逐行逆序
class Solution:
    def rotate(self, matrix: List[List[int]]) -> None:
        """
        Do not return anything, modify matrix in-place instead.
        """
        n=len(matrix)
        # matrix2 = [[0 for b in range(n)] for b in range(n)]
        #
        #
        # for i in range(n):
        #     for j in range(n):
        #         matrix2[j][i]=matrix[i][j]
        # matrix=[row[:] for row in matrix2]
        # for x in range(n):
        #     matrix[x]=matrix[x][::-1]
        for i in range(n):
            for j in range( i,n):
                matrix[i][j],matrix[j][i]=matrix[j][i],matrix[i][j]
        for x in range(n):
            matrix[x]=matrix[x][::-1]
        print(matrix)




lll=Solution()
print(lll.rotate([[1,2,3],[4,5,6],[7,8,9]]))


"""
输入：matrix = [[1,2,3],
              [4,5,6],
              [7,8,9]]
              
        输出：[[7,4,1],
             [8,5,2],
             [9,6,3]]

"""